// 假数据测试方法 

var uuid = function () {
    var uuid = '';
    for (var i = 1; i <= 32; i++) {
        var n = Math.floor(Math.random() * 16.0).toString(16);
        uuid += n;
    }
    return uuid;
};

var TreeId = [uuid(), uuid(), uuid(), uuid(), uuid(), uuid(), uuid(), uuid(), uuid(), uuid()];


var treeData = [
    { title: '父级1', id: TreeId[0], parentId: null },
    { title: '父级2', id: TreeId[1], parentId: null },

    { title: '子级1', id: TreeId[2], parentId: TreeId[0] },
    { title: '子级2', id: TreeId[3], parentId: TreeId[0] },

    { title: '子级3', id: TreeId[4], parentId: TreeId[1] },
    { title: '子级4', id: TreeId[5], parentId: TreeId[1] },

    { title: '次子级1', id: TreeId[6], parentId: TreeId[2] },
    { title: '次子级2', id: TreeId[7], parentId: TreeId[2] },
    { title: '次子级3', id: TreeId[8], parentId: TreeId[4] },
    { title: '次子级4', id: TreeId[9], parentId: TreeId[5] },
]

var Cols = [{
    key: 'Text',
    title: 'Text',
    slot: 'Text',
    type: 'Text',
}, {
    key: 'Select',
    title: 'Select',
    slot: 'Select',
    type: 'Select',
    dist: [
        { value: 1, name: 'SelectValue1', },
        { value: 2, name: 'SelectValue2', },
        { value: 3, name: 'SelectValue3', },
        { value: 4, name: 'SelectValue4', },
    ],
}, {
    key: 'SelectEdit',
    title: 'SelectEdit',
    slot: 'SelectEdit',
    type: 'SelectEdit',
    dist: [
        { value: 1, name: 'SelectEditValue1', },
        { value: 2, name: 'SelectEditValue2', },
        { value: 3, name: 'SelectEditValue3', },
        { value: 4, name: 'SelectEditValue4', },
    ],
}, {
    key: 'action',
    title: 'action',
    slot: 'action',
    type: 'action',
    width: '70px'
}];

const randomNum = (min, max) => parseInt(Math.random() * (max - min + 1) + min, 10);

var renderTableData = function () {
    var TableCols = JSON.parse(JSON.stringify(Cols));
    var TableData = [];
    var length = randomNum(10, 50);
    for (let i = 0; i < length; i++) {
        TableData.push({
            id: uuid(),
            Text: randomNum(10, 20),
            Select: randomNum(1, 4),
            SelectEdit: randomNum(1, 4),
        });
    }
    return {
        cols: TableCols,
        data: TableData
    }
}


export default {
    treeData() {
        return JSON.parse(JSON.stringify(treeData));
    },
    activeData() {
        return JSON.parse(JSON.stringify([TreeId[6], TreeId[3], TreeId[8]]));
    },
    tableData() {
        return renderTableData();
    }
}




